package control.table
{
	import core.Model;
	import core.View;
	
	import events.SitEvent;
	
	import global.GameState;
	
	import view.gift.Gift;
	
	public class GiftControl
	{
		
		
		public function GiftControl()
		{
			initListener();
		}
		
		private function initListener():void
		{
			Model.getInstance().sitModel.addEventListener(SitEvent.SIT_GIVE_GIFT,onGiveGift);	
		}
		
		private function onGiveGift(event:SitEvent):void
		{
			var giftId:String = event.animateId;
			var gift:Gift = new Gift(giftId);
			var fromSitId:int = event.fromId;
			var toSitId:int = event.toId;
			
			var fx:int = GameState.sitButXYS[fromSitId][0];
			var fy:int = GameState.sitButXYS[fromSitId][1];
			var tx:int = GameState.sitButXYS[toSitId][0];
			var ty:int = GameState.sitButXYS[toSitId][1];
			
			View.getInstance().tableLayer.addEmote(gift);
			gift.send(fx,fy,tx,ty);
		}
	}
}